home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / scpainterex_ps2.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-09  |  7.3 KB  |  234 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7. /* This file is part of the KDE project
  8.    Copyright (C) 2001, 2002, 2003 The Karbon Developers
  9.  
  10.    This library is free software; you can redistribute it and/or
  11.    modify it under the terms of the GNU Library General Public
  12.    License as published by the Free Software Foundation; either
  13.    version 2 of the License, or (at your option) any later version.
  14.  
  15.    This library is distributed in the hope that it will be useful,
  16.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18.    Library General Public License for more details.
  19.  
  20.    You should have received a copy of the GNU Library General Public License
  21.    along with this library; see the file COPYING.LIB.  If not, write to
  22.    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23.    Boston, MA 02111-1307, USA.
  24. */
  25. /* Adapted for Scribus 22.08.2003 by Franz Schmid */
  26. /* Adapted for Scribus 15.01.2006 by Jean Ghali */
  27.  
  28. #ifndef __SCPAINTEREX_PS2_H__
  29. #define __SCPAINTEREX_PS2_H__
  30.  
  31. // libart wrapper
  32.  
  33. #include <QGlobalStatic>
  34. #include <QColor>
  35. #include <QFont>
  36. #include <QMatrix>
  37. #include <QList>
  38. #include <QPixmap>
  39. #include <QStack>
  40. #include <QTextStream>
  41.  
  42. #include "scribusapi.h"
  43. #include "scconfig.h"
  44. #include "fpoint.h"
  45. #include "fpointarray.h"
  46. #include "vgradient.h"
  47.  
  48. #include "scpainterexbase.h"
  49. #include CMS_INC
  50.  
  51. class ScribusDoc;
  52.  
  53. class ScPs2OutputParams
  54. {
  55. public:
  56.     ScPs2OutputParams(ScribusDoc* doc = NULL);
  57.     ScPainterExBase::ColorMode colorMode;
  58.     ScribusDoc* document;
  59.     bool reloadImages;
  60.     int resolution;
  61.     bool useProfiles;
  62.     bool toGray;
  63.     bool mirrorH;
  64.     bool mirrorV;
  65.     QString outputProfile;
  66.     cmsHPROFILE   hProfile;
  67.     cmsHTRANSFORM rgbToOutputColorTransform;
  68.     cmsHTRANSFORM rgbToOutputImageTransform;
  69.     cmsHTRANSFORM cmykToOutputColorTransform;
  70.     cmsHTRANSFORM cmykToOutputImageTransform;
  71. };
  72.  
  73. class SCRIBUS_API ScPainterEx_Ps2 : public ScPainterExBase
  74. {
  75. public:
  76.  
  77.     ScPainterEx_Ps2( QIODevice* iodev, QRect& rect, ScPs2OutputParams& options );
  78.     virtual ~ScPainterEx_Ps2();
  79.  
  80.     virtual int supportedColorModes() { return (int) (rgbMode|cmykMode); }
  81.     virtual ColorMode preferredColorMode() { return m_colorMode; }
  82.     virtual void setPreferredColorMode(ScPainterEx_Ps2::ColorMode colorMode) { m_colorMode = colorMode; }
  83.     virtual ImageMode imageMode();
  84.  
  85.     virtual void begin();
  86.     virtual void end();
  87.     virtual void clear();
  88.     virtual void clear( ScColorShade & );
  89.  
  90.     // matrix manipulation
  91.     virtual void setWorldMatrix( const QMatrix & );
  92.     virtual const QMatrix worldMatrix();
  93.     virtual void translate( double, double );
  94.     virtual void rotate( double );
  95.     virtual void scale( double, double );
  96.  
  97.     // drawing
  98.     virtual void moveTo( const double &, const double & );
  99.     virtual void lineTo( const double &, const double & );
  100.     virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 );
  101.     virtual void newPath();
  102.     virtual void closePath();
  103.     virtual void fillTextPath();
  104.     virtual void strokeTextPath();
  105.     virtual void fillPath();
  106.     virtual void strokePath();
  107.     virtual void setFillRule( bool fillRule );
  108.     virtual bool fillRule() { return m_fillRule; }
  109.     virtual void setFillMode( int fill );
  110.     virtual int  fillMode() { return m_fillMode; }
  111.     virtual void setGradient( VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc = FPoint(0,0));
  112.     virtual void setPattern ( ScPattern* pattern, QMatrix& patternTransform );
  113.     virtual void setClipPath();
  114.  
  115.     virtual void drawImage( ScImage *image, ScPainterExBase::ImageMode mode );
  116.     virtual void drawRGBImage_ps2( ScImage *image );
  117.     virtual void drawCMYKImage_ps2( ScImage *image );
  118.  
  119.     virtual bool hasAlphaChannel( ScImage* image );
  120.  
  121.     virtual void setupPolygon(FPointArray *points, bool closed = true);
  122.     virtual void drawPolygon();
  123.     virtual void drawPolyLine();
  124.     virtual void drawLine(FPoint start, FPoint end);
  125.     virtual void drawRect(double, double, double, double);
  126.  
  127.     // pen + brush
  128.     virtual ScColorShade pen();
  129.     virtual ScColorShade brush();
  130.     virtual void setPen( const ScColorShade & );
  131.     virtual void setPen( const ScColorShade &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo );
  132.     virtual void setPenOpacity( double op );
  133.     virtual void setLineWidth( double w);
  134.     virtual void setDash(const QVector<double>& array, double ofs);
  135.     virtual void setBrush( const ScColorShade & );
  136.     virtual void setBrushOpacity( double op );
  137.     virtual void setOpacity( double op );
  138.     virtual void setFont( const QFont &f );
  139.     virtual QFont font();
  140.  
  141.     // stack management
  142.     virtual void save();
  143.     virtual void restore();
  144.  
  145.     virtual void setRasterOp( int op );
  146.  
  147. protected:
  148.  
  149.     virtual void writeRGBImageToStream_Ascii85 ( ScImage* image );
  150.     virtual void writeRGBImageToStream_AsciiHex ( ScImage* image );
  151.     virtual void writeCMYKImageToStream_Ascii85( ScImage* image );
  152.     virtual void writeCMYKImageToStream_AsciiHex( ScImage* image );
  153.     virtual void writeMaskToStream ( QImage* image ); 
  154.  
  155. private:
  156.  
  157.     typedef enum {
  158.         Ascii85Encoding,
  159.         AsciiHexEncoding
  160.     } AsciiEncoding;
  161.  
  162.     /* Output stream */
  163.     QTextStream   m_stream;
  164.     ColorMode     m_colorMode;
  165.     AsciiEncoding m_encoding; 
  166.  
  167.     /* Path bounding boxes*/
  168.     QRect m_pathBBox;
  169.     QRect m_clipBBox;
  170.  
  171.     /* General output options */
  172.     ScPs2OutputParams m_options;
  173.  
  174.     /* Basic drawing functions*/
  175.     void drawVPath( int mode );
  176.     void drawGradient( VGradientEx& gradient );
  177.     void drawLinearGradient( VGradientEx& gradient, const QRect& rect );
  178.     void drawLinearGradient_RGB( VGradientEx& gradient, const QRect& rect );
  179.     void drawLinearGradient_CMYK( VGradientEx& gradient, const QRect& rect );
  180.     void drawCircularGradient( VGradientEx& gradient, const QRect& rect );
  181.     void drawCircularGradient_RGB( VGradientEx& gradient, const QRect& rect );
  182.     void drawCircularGradient_CMYK( VGradientEx& gradient, const QRect& rect );
  183.     void getPathBoundingBox( FPointArray* points, QRect& r );
  184.     void transformPoint( const FPoint& in, FPoint& out );
  185.     void transformPoints( const FPoint* in, FPoint* out, uint length );
  186.  
  187.     void putColor( ScColorShade& colorShade, bool doFill );
  188.  
  189.     unsigned int m_width;
  190.     unsigned int m_height;
  191.     unsigned int m_x;
  192.     unsigned int m_y;
  193.     QMatrix m_pageTrans;
  194.     QMatrix m_matrix;
  195.     QFont m_font;
  196. /* Filling */
  197.     ScColorShade m_fillColor;
  198.     double m_fillTrans;
  199.     bool   m_fillRule;
  200.     int    m_fillMode;            // 0 = none, 1 = solid, 2 = gradient
  201.     int    m_gradientMode;        // 1 = linear, 2 = radial
  202. /* Stroking */
  203.     ScColorShade m_strokeColor;
  204.     double m_strokeTrans;
  205.     double m_lineWidth;
  206.  
  207. /* Line End Style */
  208.     Qt::PenCapStyle m_lineEnd;
  209. /* Line Join Style */
  210.     Qt::PenJoinStyle m_lineJoin;
  211. /* The Dash Array */
  212.     QVector<double> m_array;
  213.     double m_offset;
  214. /* Transformation Stack */
  215.     QStack<QMatrix> m_stack;
  216. /* Zoom Factor of the Painter */
  217.     double m_zoomFactor;
  218.  
  219. /* Some data to describe state of drawing */    
  220.     bool m_pathIsClosed;
  221.     bool m_drawingClosedPath;
  222. /* Drawing surface dimensions */
  223.     double m_deviceDimX;
  224.     double m_deviceDimY;
  225. /* Device resolutions */
  226.     double m_deviceResX;
  227.     double m_deviceResY;
  228.  
  229. /* Color conversion function */
  230.     void   transformImage( QImage* image, uchar* data, int scan);
  231. };
  232.  
  233. #endif
  234.